"""author: songzhiqiang
   data: 2021/10/29
   project: 2021-10-28-弹珠游戏
"""
#######################空气质量######################
while 1:
    input('按任意键开始，按q退出')
    pm = input("请输入空气质量")
    if pm == "q":
        break
    pm =int(pm)
    if 0 < pm <= 50:
        print("空气质量为优")
    elif 51 < pm <= 100:
        print("空气质量为良")
    elif 101 < pm <= 150:
        print("轻度污染")
    elif 151 < pm <= 200:
        print("中度污染")
    elif 201 < pm <= 300:
        print("重度污染")
    else:
        print("严重污染")



###################游戏######################

import random

num = 0
fail = 0
gold = 1000
print("输入exit退出")
while 1:
    if gold < 100:
        break
    guess = input("请猜猜大小")
    if guess == "exit":
        break
    d = random.choices('123456', k=3)
    sum = int(d[1]) + int(d[2]) + int(d[0])
    if 3 <= sum <= 10:
        c = "小"
    else:
        c = "大"
    if guess == c:
        num += 1
        gold += 100
        print(f"你赢了，剩余金豆{gold}")
    else:
        fail += 1
        gold -= 100
        print(f"你输了，剩余金豆{gold}")
print(f"您玩了{num + fail}次 胜率为:{num / (num + fail)}")


###############九九乘法表######################
for i in range(1,10):
    for j in range(1,i+1):
       print(f" {j}*{i}={i*j}",end="")
    print("\n")

#################千分位格式化####################


a = input("请输入数字\n")
j = 0
a = a[::-1]
str2 = ""
if a.isnumeric():
    while j < len(a) :
     str1 = a[j:j + 3]
     str2 += "," +str1
     j = j +3
else:
    print("这不是纯数字")
b = str2.strip(",")
print(b[::-1])
